package com.my.study.algorithm.leetcode.huwei;

import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * 最后一个字符串长度
 * 
 * @author Carlos
 * @version 1.0.0
 * @date 2023/2/27 7:40
 */
public class LastStrLen {

    public static void main(String[] args) throws IOException {
//        Scanner in = new Scanner(System.in);
//
//        String s = in.nextLine();
//
//        String[] str = s.split(" ");
//        
//        int len = str[str.length - 1].length();
//
//        System.out.println(len);
        int lastStrLen = lastStrLen();
        System.out.println(lastStrLen);
    }
    
    private static int lastStrLen() throws IOException {
        InputStream inputStream = System.in;
        int len = 0;
        char c;
        
        while ('\n' != (c = (char) inputStream.read())) {
            len++;
            if (c == ' ') {
                len = 0;
            }
        }
        return len;
    }
    
}
